#ifndef SVGHELPER_H
#define SVGHELPER_H

#include <QColor>
#include <QDomDocument>

class SvgHelper
{
public:
    SvgHelper() = default;
    explicit SvgHelper(const QString &filename);

    static bool isSvgFile(const QString &filename);
    static QByteArray filled(const QString &filename, const QColor &color);
    static QByteArray opacityOnly(const QString &filename, float alpha);
    static QByteArray cloned(const QString &filename);

    /**
     * @brief
     * fill svg with the given color
     * @note
     * svg's rule of filling color is rgba, but QSvgWidget class cannot recognize rgba.
     * So an extra attribute called "fill-opacity" would be set in svg files
     * in order to display the effect of opacity.
     */
    QByteArray filled(const QColor &color) const;
    QByteArray opacityOnly(float alpha) const;
    QByteArray cloned() const;

    SvgHelper &setFileName(const QString &fileName);

private:
    QDomDocument doc;
};

#endif // SVGHELPER_H
